package com.JDK.Lock;


import java.util.concurrent.TimeUnit;

public class DeadLock {

      static  final Integer lock1 = 1;

      static final Integer lock2 = 2;

    public static void main(String[] args) {

        new Thread(() ->{
            synchronized (lock1){
                try {
                    TimeUnit.SECONDS.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                synchronized (lock2){
                    System.out.println("I GOT THIS !!!");
                }
            }
        },"Thread-1").start();

        new Thread(() ->{
            synchronized (lock2){
                try {
                    TimeUnit.SECONDS.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                synchronized (lock1){
                    System.out.println("I GOT THIS !!!");
                }
            }
        },"Thread-2").start();

    }
}
